using System;
using System.Threading;

namespace CL
{
    public class CLFiberManager : CLSingleton<CLFiberManager>, ICLSingletonAwake, ICLSingletonReverseDispose
    {
        private CLFiber fiber = null;
        private int idGenerator = 10000000;
        public void Awake()
        {
            int fiberId = Interlocked.Increment(ref this.idGenerator);
            fiber = new(fiberId, 0, "");
            CLFiber.Instance = fiber;
          //  CLLog.Info("CLFiberManager Awake");
        }

        public void Update()
        {
            fiber?.Update();
        }

        public void LateUpdate()
        {
            fiber?.LateUpdate();
        }

        protected override void Destroy()
        {
            fiber.Dispose();
            this.fiber = null;
        }

        public CLFiber GetFiber()
        {
            return fiber;
        }

    }
}
